package pl.edu.pw.perg.compinfodb.dao;

import java.util.List;
import java.util.Set;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import pl.edu.pw.perg.compinfodb.entities.Connector;
import pl.edu.pw.perg.compinfodb.entities.VirtualElement;

public class ConnectorDAO extends GenericSpringDAO<Connector> implements IConnectorDAO {

  @Override
  public void deleteAll() {
    Session s = getSession();
    Query sql = s.createSQLQuery("delete from internal_connections");
    sql.executeUpdate();
    Query q = s.createQuery("delete from Connector"); 
    q.executeUpdate();
  }

public List<Connector> findInputConnectors(VirtualElement virtualElement) {
	return findByCriteria( Restrictions.eq("elementOut", virtualElement));
}

public List<Connector> findOutputConnectors(VirtualElement virtualElement) {
	return findByCriteria( Restrictions.eq("elementIn", virtualElement));
}
}
